package com.co.user.feign;

import com.co.user.pojo.User;
import com.co.common.entity.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ldl.plus
 * @date 2020年06月22日  0:41
 */
@FeignClient(name = "user")
@RequestMapping("/user")
public interface UserFeign {

    /**
     * UsUser分页条件搜索实现
     *
     * @param user
     * @param page
     * @param size
     * @return
     */
    @PostMapping(value = "/search/{page}/{size}")
    Result<PageInfo<User>> findPage(@RequestBody(required = false) User user, @PathVariable("page") int page, @PathVariable("size") int size);

    /**
     * UsUser分页搜索实现
     *
     * @param page:当前页
     * @param size:每页显示多少条
     * @return
     */
    @GetMapping(value = "/search/{page}/{size}")
    Result<PageInfo<User>> findPage(@PathVariable("page") int page, @PathVariable("size") int size);

    /**
     * 多条件搜索品牌数据
     *
     * @param user
     * @return
     */
    @PostMapping(value = "/search")
    Result<List<User>> findList(@RequestBody(required = false) User user);

    /**
     * 根据ID删除品牌数据
     *
     * @param id
     * @return
     */
    @DeleteMapping(value = "/{id}")
    Result delete(@PathVariable("id") String id);

    /**
     * 修改UsUser数据
     *
     * @param user
     * @param id
     * @return
     */
    @PutMapping(value = "/{id}")
    Result update(@RequestBody User user, @PathVariable("id") String id);

    /**
     * 新增UsUser数据
     *
     * @param user
     * @return
     */
    @PostMapping
    Result add(@RequestBody User user);

    /**
     * 根据ID查询UsUser数据
     *
     * @param username
     * @return
     */
    @GetMapping("/{username}")
    Result<User> findById(@PathVariable("username") String username);

    /**
     * 查询UsUser全部数据
     *
     * @return
     */
    @GetMapping
    Result<List<User>> findAll();

    /**
     * 根据用户名查询用户信息
     *
     * @param username
     * @return
     */
    @GetMapping("/load/{username}")
    public User findUserInfo(@PathVariable("username") String username);

    /**
     * 注册
     *
     * @param user
     * @return
     */
    @PostMapping("/signup")
    @ResponseBody
    public Result signup(@RequestBody User user);
}
